<?php

namespace app\home\controller;

use \think\Db;
use \app\common\Pay;
use \app\common\TenWePay;
use \app\common\model\Config;

class Test
{

	public function __construct()
	{

	}

	public function index()
	{

		//\think\Queue::push('\app\pay\job\AliSend@reset_password', ['agent_id' => 1]);
		//\think\Queue::push('\app\pay\job\AliSend@reset_password', ['merchant_id' => 1]);
		//\think\Queue::push('\app\pay\job\AliSend@add_agent', ['agent_id' => 1]);
		//\think\Queue::push('\app\pay\job\AliSend@add_merchant', ['merchant_id' => 1]);
		//\think\Queue::push('\app\pay\job\AliSend@audit_merchant', ['agent_id' => 1, 'merchant_id' => 1]);
		/*
		$amount = input('param.amount');
		$client = stream_socket_client('tcp://127.0.0.1:3456', $errno, $errmsg, 1);
		$data = [
			'device_id'=>'39',
			'status' => '',
			'message'=> [
				'command' => 'speech',
				'contents' => [
					'text' => '收款成功',
					'amount' => $amount,
				]
			]
		];
		$text = JSON($data);
		fwrite($client, $text . "\n");
		$data['status'] = fread($client, 2048);
		echo JSON($data);
		exit();
		*/

		/*
		$WeChat = \app\common\WeChatConsole::init();
		$Template = $WeChat->load('Template');
		try {
			$res = $Template->getAllPrivateTemplate();
			print_r($res);
		} catch (\Exception $e) {
			print_r($e->getMessage());
		}
		exit;
		try {
			$res = $Template->addTemplate('OPENTM418123148');
			print_r($res);
		} catch (\Exception $e) {
			print_r($e->getMessage());
		}
		try {
			$res = $Template->addTemplate('OPENTM418123151');
			print_r($res);
		} catch (\Exception $e) {
			print_r($e->getMessage());
		}
		exit;
		*/

		/*
		$WeChat = \app\common\WeChatConsole::init();
		$Template = $WeChat->load('Template');
		try {
			$res = $Template->getIndustry();
			print_r($res);
		} catch (\Exception $e) {
			print_r($e->getMessage());
		}
		if($res['primary_industry']['first_class'] != 'IT科技' || $res['primary_industry']['second_class'] != '互联网|电子商务' || $res['secondary_industry']['first_class'] != '餐饮' || $res['secondary_industry']['second_class'] != '餐饮') {
			try {
				$res = $Template->setIndustry(1, 10);
				print_r($res);
			} catch (\Exception $e) {
				print_r($e->getMessage());
			}
		}
		*/

	}

	public function micro()
	{

		$TenWePay = new TenWePay();

		$PayWeixin = new \app\common\PayWeixin();

		$business_code = get_order_number($TenWePay->mch_id . '_');

		$BizContent = [
			'version' => '3.0',
			'cert_sn' => $TenWePay->wx_SerialNumber,
			'business_code' => $business_code,
			'contact' => $TenWePay->encrypt('朱锦延'),
			'contact_phone' => $TenWePay->encrypt('13306182230'),
			'contact_email' => $TenWePay->encrypt('zhu@iuui.cn'),
			'id_card_copy' => '',
			'id_card_national' => '',
			'id_card_name' => $TenWePay->encrypt('朱锦延'),
			'id_card_number' => $TenWePay->encrypt('320283198602132696'),
			'id_card_valid_time' => '',
			'account_bank' => '建设银行',
			'bank_name' => '',
			'bank_address_code' => '',
			'account_name' => $TenWePay->encrypt('朱锦延'),
			'account_number' => $TenWePay->encrypt('6227001242230247074'),
			'store_name' => '',
			'store_address_code' => '',
			'store_street' => '',
			'store_entrance_pic' => '',
			'indoor_pic' => '',
			'merchant_shortname' => '',
			'service_phone' => '',
			'product_desc' => '',
			'rate' => ''
		];
		$res = $PayWeixin->post('Applyment/micro_submit', [
			'BizContent' => $BizContent
		]);
		print_r($res);

	}

}

